/*

Summary:
Tab class.

Remark:
None.

Version:
0.1.0

LastUpdatedDate:
2012-09-28

*/

#pragma once

#include <vector>
#include "ControlWindow.h"
#include "..\Tool\Event.h"
#include "..\..\Enum.h"


namespace Zaf {
namespace Mwl {
namespace __Internal {
	class WndProcPicker;
}


class TabPage;


ZafEnum(TabAppearance, DWORD) {
	Tabs,
	Buttons,
	FlatButtons,
};


ZafEnum(TabAlignment, DWORD) {
	Top,
	Bottom,
	Left,
	Right,
};



struct SelectedPageChangingArgs : public EventArgs {

	SelectedPageChangingArgs() : Cancel(false) { }

	bool Cancel;
};



struct SelectedPageChangedArgs : public EventArgs {

};



class Tab : public ControlWindow {

public:
	Tab();
	explicit Tab(WORD id);
	virtual ~Tab();

	TabAlignment GetAlignment() const;
	void SetAlignment(TabAlignment value);

	TabAppearance GetAppearance() const;
	void SetAppearance(TabAppearance value);

	int InsertPage(TabPage& page, int pos = -1);
	bool DeletePage(int index);

	TabPage* GetPage(int pos) const;

	int GetSelectedIndex() const;
	void SetSelectedIndex(int value);

	void Clear();
	int GetCount() const;

	Event<SelectedPageChangingArgs&> SelectedPageChangingEvent;
	Event<SelectedPageChangedArgs&> SelectedPageChangedEvent;

protected:
	LRESULT DefWndProc(const WndMsg& msg);

private:
	void CommonConstructor();

	HWND CreateConcreteWindow();
	LRESULT OnNotify(const WndMsg& msg);

	void ShowPage(int index);
	void HidePage(int index);
	void AdjustPage(TabPage* page);

	static const wchar_t* const ClassName;
	static __Internal::WndProcPicker TabWndProc;
};


}
}